package com.jpratice.spring.basic;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.jpratice.util.JpraticeUtil;

/**
 * Copyright 2008 @ jPractices v 1.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 *
 * http://ganesh.gowtham@googlepages.com mail id : ganesh.gowtham@gmail.com
 * @author Ganesh Gowtham G R
 */

/**
 * class gives the brief idea about the Constructor Injection & setter injection 
 * refer :http://www.martinfowler.com/articles/injection.html
 */
public class BasicSpringTests {

	/**
	 * @param args
	 */

	public static void main(String[] args) {

		BeanFactory beanFactory = new ClassPathXmlApplicationContext(
				"com/jpratice/spring/basic/basicContext.xml");
		JpraticeUtil.display("  - - - - wheel details injected to Car through the method injection");
		//example 1 Wheel details injected to Car by method injection
		Car carbyMethodInjection = (Car)beanFactory.getBean("carByMethodInjection");
		JpraticeUtil.display(carbyMethodInjection.getLeftFrontWheel());
		JpraticeUtil.display(carbyMethodInjection.getLeftRearWheel());
		JpraticeUtil.display(carbyMethodInjection.getRightFrontWheel());
		JpraticeUtil.display(carbyMethodInjection.getRightRearWheel());
		// example 2 details of wheel injected via constructor injection
		JpraticeUtil.display(" - - --  wheel detais injected via constructor injection");
		JpraticeUtil.display(carbyMethodInjection.getExtraWheel());
	}

}
